export const diySysPageMixin = {
	data() {
		return {};
	},
	computed: {
		menuButtonInfo() {
			// #ifndef APP-PLUS || H5
			let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
			return menuButtonInfo;
			// #endif
		},
		systemInfo() {
			const res = uni.getSystemInfoSync();
			return res;
		},
		moduleCss() {
			if (this.propsData && this.propsData.moduleCss) {
				return this.propsData.moduleCss;
			}
		},
		outModuleCss() {
			if (!this.propsData) return {};
			let style = Object.assign({}, this.propsData.moduleCss);
			style.margin = `${style.marginTop* 2||0}rpx 0 ${style.margin* 2}rpx 0`;
			
			 if(style.ones==1){
			        if (style.paddingLift||style.paddingRight) style.padding = `0 ${style.paddingRight*2}rpx 0 ${style.paddingLift*2}rpx`;
			      }else{
			        if (style.padding) style.padding = `0 ${style.padding*2||0}rpx`;
			}
			
			if (style.borderRadius)
				style["borderRadius"] = `${style.borderRadius * 2}rpx`;
			let obj = {
				margin: style.margin,
				borderRadius: style.borderRadius,
				padding: style.padding,
				position: "relative",
				overflow: "hidden",
			};
			return obj;
		},
		// 混入模块背景设置
		moduleBgCss() {
			if (!this.propsData) return {};
			let style = Object.assign({}, this.propsData.moduleCss);
			if (!style.useBackground) {
				return {
					background: "inherit",
				};
			}
			if (style.borderRadiusTop || style.borderRadiusRight || style.borderRadiusBottom || style
				.borderRadiusLift) {
				style["borderRadius"] =
					`${style.borderRadiusTop* 2}rpx ${style.borderRadiusRight* 2}rpx ${style.borderRadiusBottom* 2}rpx ${style.borderRadiusLift* 2}rpx`;
			} else {
				if (style.borderRadius) style["borderRadius"] = `${style.borderRadius* 2}rpx`;
			}
			let hSpace = style.padding;
			let obj = {
				backgroundColor: style.backgroundColor || "",
				backgroundImage: style.backgroundImage || "",
				backgroundRepeat: style.backgroundRepeat || "no-repeat",
				backgroundSize: style.backgroundSize || "100% 100%",
				opacity: style.opacity || "",
				borderRadius: style["borderRadius"]  || "",
				width: `calc(100% - ${hSpace * 4}rpx)`,
				left: hSpace * 2 + "rpx",
			};
			return obj;
		},
		// 混入模块背景设置
		moduleBgNoCalcCss() {
			if (!this.propsData) return {};
			let style = Object.assign({}, this.propsData.moduleCss);
			if (!style.useBackground) {
				return {
					background: "inherit",
				};
			}
			let obj = {
				backgroundColor: style.backgroundColor || "",
				backgroundImage: style.backgroundImage || "",
				backgroundRepeat: style.backgroundRepeat || "no-repeat",
				backgroundSize: style.backgroundSize || "100% 100%",
				opacity: style.opacity || "",
				borderRadius: style.borderRadius * 2 + "rpx" || "",
			};
			return obj;
		},
	},
	filters: {
		priceBeforeZero(val) {
			if (val.indexOf(".") < 0) return `${val}.`;
			return val.substr(0, val.indexOf("."));
		},
		priceAfterZero(val) {
			if (val.indexOf(".") < 0) return "00";
			return val.substr(val.indexOf("."), val.length);
		},
	},
	methods: {
		fontCss(css) {
			if (css.fontNum && css.fontNum > 0) {
				css.fontSize = css.fontNum * 2 + "rpx";
				return css;
			} else {
				return css;
			}
		},
	},
};